<?php 
	
	class FTAGoogleSiteMap extends FTASiteMap {
		
		var $optionalElements = array("priority","lastmod","changefreq");
		

		function generateSiteMap(){ 
			
			$ret = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
			$ret .=  "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
			$ret .=  parent::generateSiteMap();
			$ret .= "</urlset>\n";
			
			return $ret;
		}
		
		function generateNode($node){
			
			$ret="";
			if (array_key_exists('link',$node)) {
				$ret = " <url>\n";
				$ret .= "  <loc>".CMS_HTTP_HOST.$node['link']."</loc>\n";
				
				foreach ($this->optionalElements as $optionalElement)
					$ret .= $this->getOptionalElement($optionalElement, $node);
				
				$ret .= " </url>\n";
			} else {
				$ret .= $this->rGenerateSiteMap($node);
			}
			// else			
			// print_r($node);
			
			$ret .= parent::generateNode($node);
			
			return $ret;
		}
		
		function getOptionalElement($elementName,$node){
			if (key_exists($elementName,$node) && 0 < strlen($node[$elementName])) {
				return "<$elementName>".$node[$elementName]."</$elementName>\n";
			}
		}
	}